﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
</head>
<body>
    <div class="page">
        <header>
            <div id="title">
                <h1>Dark Deer Hotel</h1>
            </div>
            <div id="logindisplay">
                @Html.Partial("_LogOnPartial")
            </div>
            <nav>
                @{
                    var menus = new[]
                    {
                           new { LinkText=Resources.Global.Home, ActionName="Index",ControllerName="Home",Roles="All"  },
                           new { LinkText=Resources.Global.About, ActionName="About",ControllerName="Home",Roles="Anonymous"  },
                           new { LinkText=Resources.Global.RoomRent, ActionName="Index",ControllerName="OrderRoom",Roles="Anonymous"  },
                           new { LinkText=Resources.Global.HallRent, ActionName="Index",ControllerName="HallOrder",Roles="Anonymous"  },
                           
                           new { LinkText=Resources.Global.MoveInOut, ActionName="Index",ControllerName="CheckInOut",Roles="Reception"  },
                           new { LinkText=Resources.Global.RoomService, ActionName="Index",ControllerName="RoomService",Roles="Cleaners"  },
                           new { LinkText=Resources.Global.RoomService, ActionName="Index",ControllerName="RoomService",Roles="Repairman"  },
                           new { LinkText=Resources.Global.Assignment, ActionName="Index",ControllerName="Assignment",Roles="Cleaners"},
                           new { LinkText=Resources.Global.Assignment, ActionName="Index",ControllerName="Assignment",Roles="Repairman"},
                           new { LinkText=Resources.Global.Assignment, ActionName="Index",ControllerName="Assignment",Roles="Reception"},
                           new { LinkText=Resources.Global.Current, ActionName="Current",ControllerName="RoomService",Roles="Cleaners"},
                           new { LinkText=Resources.Global.Current, ActionName="Current",ControllerName="RoomService",Roles="Repairman"},
                          
                           new { LinkText=Resources.Global.AddAccount, ActionName="Index",ControllerName="Administrator",Roles="Administrators"  },
                           new { LinkText=Resources.Global.DeleteAccount, ActionName="Delete",ControllerName="Administrator",Roles="Administrators"  },
                           new { LinkText=Resources.Global.ServiceControl, ActionName="Index",ControllerName="AdministratorService",Roles="Administrators"  },
 
                    };
                }
                <ul id="menu">
                    @if (HttpContext.Current.User.Identity.IsAuthenticated)
                    {
                        String[] roles = Roles.GetRolesForUser();
                        List<string> added = new List<string>();
                        var links = from item in menus
                                    where item.Roles.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                                    .Any(x => roles.Contains(x) || x == "All")
                                    select item;
                        foreach (var link in links)
                        {
                            if (added.Contains(link.LinkText))
                            {

                            }
                            else
                            {
                                added.Add(link.LinkText);
                            @: <li> @Html.ActionLink(link.LinkText, link.ActionName, link.ControllerName)</li>
                        }
                        }
                    }
                    else
                    {
                        var links = from item in menus
                                    where item.Roles.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                                    .Any(x => new String[] { "All", "Anonymous" }.Contains(x))
                                    select item;
                        foreach (var link in links)
                        {
                            @: <li> @Html.ActionLink(link.LinkText, link.ActionName, link.ControllerName)</li>
                        }
                    }
                </ul>
            </nav>
        </header>
        <section id="main">
            @RenderBody()
        </section>
        <footer>
        </footer>
    </div>
</body>
</html>
